package com.jack.design_patterns.creational.builder.static_innerclass_chain;

public class Phone {

    // 必传字段
    private String cpu;
    // 非必传字段
    private String disk;
    // 非必传字段
    private String memory;
    // 非必传字段
    private String camera;

    private Phone() {

    }

    public static class PhoneBuilder {
        Phone phone = new Phone();
        private PhoneBuilder(String cpu) {
            phone.cpu = cpu;
        }
        public PhoneBuilder disk(String disk) {
            phone.disk = disk;
            return this;
        }
        public PhoneBuilder memory(String memory) {
            phone.memory = memory;
            return this;
        }
        public PhoneBuilder camera(String camera) {
            phone.camera = camera;
            return this;
        }
        public Phone build() {
            return phone;
        }
    }

    public static PhoneBuilder phoneBuilder(String cpu) {
        return new PhoneBuilder(cpu);
    }


    @Override
    public String toString() {
        return "Phone{" +
                "cpu='" + cpu + '\'' +
                ", disk='" + disk + '\'' +
                ", memory='" + memory + '\'' +
                ", camera='" + camera + '\'' +
                '}';
    }
}
